package com.dzx.design.structural.flyweight;

import java.util.HashMap;
import java.util.Map;

/**
 * @author dzx
 * @ClassName:
 * @Description: 享元模式
 * @date 2019年08月08日 13:56:20
 */
public class EmployeeFactory {
    private static final Map<String, Employee> EMPLOYEE_MAP = new HashMap<String, Employee>();

    public static Employee getManager(String department) {
        Manager manager = (Manager) EMPLOYEE_MAP.get(department);
        if (manager == null) {
            System.out.print("创建部门经理：" + department);
            manager = new Manager(department);
            String reportContent = department + "部门汇报：此次报告的主要内容是....";
            System.out.println("创建报告");
            manager.setReportContent(reportContent);
            EMPLOYEE_MAP.put(department, manager);
        }
        return manager;
    }


}
